<template>
	<view class="newPassword">
		<view>请为你的账号************设置支付的密码</view>
		<input type="text" v-model="password" value="" placeholder="6-10位密码(不能全字母)" />
		<input type="text" v-model="aginpassword" value="" placeholder="请再次输入" />
		<button type="default" @click="savePassword">保存新密码</button>
		<!--//判断2此输入的密码是否一样 弹框  -->
		<u-top-tips ref="uTips"></u-top-tips>
		<!-- 支付密码设置成功 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		createNamespacedHelpers
	} from 'vuex';
	const {
		mapActions,
		mapState
	} = createNamespacedHelpers('user');
	export default {
		data() {
			return {
				password: "",
				aginpassword: ""
			}
		},
		methods: {
			...mapActions(['addPayPad']),
			//新增支付密码
		  async	savePassword() {
				//判断2此输入的密码是否一样
				if (this.password == this.aginpassword) {
                   const data=await this.addPayPad({
					   userPayPad:this.aginpassword
				   })
				   console.log("data",data)
				   if(data.code==10001){
					   //成功设置支付密码跳转到充值页面
					   this.$refs.uToast.show({
					   	title: '密码设置成功',
					   	type: 'success',
					   	url: '/pages/myWallet/myWallet'
					   })
				   }
				} else {
					this.$refs.uTips.show({
						title: '2次输入的密码不一致',
						type: 'error',
						duration: '2300'
					})
				}
			}
		}
	}
</script>


<style lang="scss" scoped>
	.newPassword {
		background-color: #fafafa;

		>view {
			background-color: #ffffff;
			color: #444343;
			text-align: center;
			font-size: 36rpx;
			padding: 20rpx;

		}

		input {
			background-color: #ffffff;
			margin: 30rpx;
			padding: 10rpx;
		}

		button {
			margin: 10rpx;

		}

		input {
			background-color: #ffffff;
			padding: 20rpx;
		}
	}
</style>
